package com.jeasonzhao.commons.logger;

public class JDKLogListener implements LogListener
{
    private java.util.logging.Logger m_logger = null;
    public JDKLogListener(java.util.logging.Logger logger)
    {
        this.m_logger = logger;
    }

    public void log(LogLevel logLevel,String strMessage,Throwable excep)
    {
        if(null == m_logger)
        {
            return;
        }
        java.util.logging.Level level = java.util.logging.Level.INFO;
        switch(logLevel)
        {
            case SYSTEM:
                level = java.util.logging.Level.CONFIG;
                break;
            case FATAL:
                level = java.util.logging.Level.SEVERE;
                break;
            case ERROR:
                level = java.util.logging.Level.CONFIG;
                break;
            case WARN:
                level = java.util.logging.Level.WARNING;
                break;
            case INFO:
                level = java.util.logging.Level.INFO;
                break;
            case DEBUG:
                level = java.util.logging.Level.FINEST;
                break;
            default:
                level = java.util.logging.Level.INFO;
                break;
        }
        m_logger.log(level,strMessage,excep);
    }
}
